//
//  URL+TS.swift
//  TSKit
//
//  Created by chenyusen on 2018/3/16.
//

import Foundation


// MARK: - 属性扩展
public extension URL {
    
    /// 获取当前URL的query键值对
    var queryItems: [String: String]? {
        return URLComponents(url: self, resolvingAgainstBaseURL: false)?
            .queryItems?
            .reduce([:], { (params: [String: String], item) -> [String: String] in
                var aParams = params
                aParams[item.name] = item.value
                return aParams
            })
    }
}
